<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <main>
        <div id="content"></div>
        <ol id="result">
        </ol>
    </main>
</body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
    const arr = [1064];

    const contentDiv = document.querySelector("#content");
    const resultOl = document.querySelector("#result");


    function ajax(v) {
        return axios({
            url: "http://127.0.0.1:8083/typeContent/queryRow",
            method: 'post',
            data: { t_type_content_pk: v }
        });

    }

    async function doStart() {
        for (const  v of arr) {
            const result = await ajax(v);
            if (result.data.status > 0) {
                createLi(result.data.result_data);
            }
        }
    }

    function createLi(data) {
        contentDiv.innerHTML = data.content;
        // 头部
        let tds = contentDiv.querySelectorAll("table>thead>tr>th");
        let a = Array.from(tds);
        const header = a.map(v => v.innerHTML);

        // 身体
        tds = contentDiv.querySelectorAll("table>tbody>tr");
        a = Array.from(tds);
        const body = [];
        a.forEach(v => {
            tds = Array.from(v.querySelectorAll("td"));
            body.push(tds.map(v => v.innerHTML));
        })

        const resultObj = {
            header,
            body
        }


        const jsonStr = JSON.stringify(resultObj);
        const sql = `update t_type_content set content = '${jsonStr}' where t_type_content_pk = ${data.t_type_content_pk};`

        const li = document.createElement("li");
        li.innerText = sql;
        resultOl.appendChild(li);
    }

    doStart();

</script>

</html>